<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Routing\Controller;
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods', 'POST, GET, OPTIONS');
header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, X-Token');
class BaseController extends Controller
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;

    public function __construct()
    {

    }

    public function response($code = 0, $message = '', $data = [])
    {
        $data = array(
            'code' => $code,
            'message' => $message,
            'data' => $data
        );
        return json_encode($data);
    }

    public function error()
    {
        return $this->response(-1, '鉴权失败');
    }
}
